package com.kh.pajx.sop.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kh.pajx.sop.dao.IGradeInfoDao;
import com.kh.pajx.sop.domain.GradeInfo;
import com.kh.pajx.sop.service.IGradeInfoService;

@Service
@Transactional
public class GradeInfoServiceImpl implements IGradeInfoService {
	
	@Resource
	private IGradeInfoDao gradeInfoDao;

	/**
	 * @see com.kh.pajx.bmp.service.school.IGradeInfoService#findGradeList(java.lang.String)
	 */
	@Override
	public List<GradeInfo> findGradeList(String sclId) {
		return gradeInfoDao.findGradeInfoList(sclId, 1);
	}
	
	/**
	 * @see com.kh.pajx.bmp.service.school.IGradeInfoService#getGradeInfoMap(java.lang.String)
	 */
	@Override
	public Map<String, String> getGradeInfoMap(String sclId) {
		Map<String,String> map = new HashMap<String, String>();
		if(StringUtils.isNotEmpty(sclId)){
			List<GradeInfo> gradeInfoList = findGradeList(sclId);
			for(GradeInfo grade : gradeInfoList){
				if(StringUtils.isNotEmpty(grade.getGraShowName())){
					if(grade.getGraName().equals(grade.getGraShowName())){
						map.put(grade.getGraId(),grade.getGraName());
					}else{
						map.put(grade.getGraId(), grade.getGraName()+"("+grade.getGraShowName()+")");
					}
				}else{
					map.put(grade.getGraId(),grade.getGraName());
				}
			}
		}else{
			// 为了效率考虑 如果未选择学校则不显示班级年级 前端页面可以设置强制要求选择学校后查询
			// 查询装载所有年级信息
		}
		return map;
	}

}
